home *** CD-ROM | disk | FTP | other *** search
- Path: news.pi.net!news
- From: cat.tech@pi.net (Remy Cool)
- Newsgroups: comp.lang.c++
- Subject: Re: BTC++ 3.1 under W95 > Dialog as Main Window gives error
- Date: Thu, 29 Feb 1996 14:31:49 GMT
- Organization: Cool Applied Technology
- Message-ID: <4h4df8$1he@neptunus.pi.net>
- References: <4h1m97$9v0@neptunus.pi.net>
- Reply-To: cool@pi.net
- NNTP-Posting-Host: hen47.pi.net
- X-Newsreader: Forte Free Agent 1.0.82
-
- cat.tech@pi.net (Remy Cool) wrote:
-
-
- >I use Borland Turbo C++ 3.1 for Windows (yes I know it's out of date) under Windows 95.
-
- >When I use a Dialog as my main window, an error -5 message pops up and the program terminates.
-
- >Can this problem be solved ???
-
- Well I found the solution myself, here it is :
-
-
- /* Cpp Source */
-
- #include <owl.h>
- #include <dialog.h>
- .....
- ....
-
- #define APPNAME "Application"
-
- class TMyWindow : public TDialog
- {
-
- public:
-
- TMyWindow();
- virtual ~TMyWindow();
- virtual LPSTR GetClassName();
- virtual void GetWindowClass(WNDCLASS&);
- };
-
-
- TMyWindow::TMyWindow() : TDialog(NULL, APPNAME)
- { }
-
- TMyWindow::~TMyWindow()
- { }
-
- /* Supply new windows class name */
-
- LPSTR TMyWindow::GetClassName()
- {
- return APPNAME;
- }
-
-
- void TMyWindow::GetWindowClass(WNDCLASS & AWndClass)
- {
- TDialog::GetWindowClass(AWndClass);
- AWndClass.hIcon = LoadIcon(GetApplication()->hInstance, APPNAME);
- }
-
-
- class TMyApp : public TApplication
- {
-
- public:
- TMyApp(LPSTR AName, HINSTANCE hInstance, HINSTANCE hPrevInstance,
- LPSTR lpCmd, int nCmdShow) :
- TApplication(AName, hInstance, hPrevInstance, lpCmd, nCmdShow) {};
-
- virtual void InitMainWindow();
- virtual void InitInstance();
- };
-
-
- void TMyApp::InitMainWindow()
- {
- MainWindow = new TMyWindow();
- }
-
- void TMyApp::InitInstance()
- {
- TApplication::InitInstance();
- }
-
- int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
- LPSTR lpCmd, int nCmdShow)
- {
-
- TMyApp MyApp(APPNAME, hInstance, hPrevInstance, lpCmd, nCmdShow);
-
- MyApp.Run();
-
- return MyApp.Status;
-
- }
-
-
-
- /* Resource .RC */
-
- #include "windows.h"
- #include "owlrc.h"
-
- Application ICON App.ico
-
- Application DIALOG DISCARDABLE LOADONCALL PURE MOVEABLE 0, 0, 100, 112
- CLASS "Application"
- STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_GROUP
- CAPTION " Application : Dialog as Main Window"
- BEGIN
- END
-
- -------------------------------------------------------------------------------------------------------------------------------------------------
-
- This works, but is there a way to let the Dialog come up maximized ?
-
- Also when I place a :
- Attr.Style | = WS_MAXIMIZE in a TWindow derived class constructor, the screen isn't maximized
- when I run the App. Why ?
-
- Regards,
-
- Remy
-
-
-
-